Skip to content

terminal: add --name-only option to show only names of failed tests#14451

Open
Vlor999 wants to merge 5 commits into
pytest-dev:mainfrom
Vlor999:main
Open

terminal: add --name-only option to show only names of failed tests#14451
Vlor999 wants to merge 5 commits into
pytest-dev:mainfrom
Vlor999:main

Conversation

@Vlor999

@Vlor999 Vlor999 commented May 9, 2026

Copy link
Copy Markdown

Add --name-only option to show only names of failed tests

Add a new CLI argument --name-only that displays only the test name or collection error headline when a test fails. This is useful for quickly identifying failures in large test suites without the noise of full tracebacks or capture sections.

  • Register --name-only in pytest_addoption.
  • Modify summary_failures_combined and summary_errors to honor the flag.
  • Add documentation in doc/en/reference/reference.rst.
  • Add regression tests in testing/test_name_only.py.
  • Add news fragment in changelog/14443.feature.rst.
  • Update AUTHORS.

  • Include documentation when adding new features.
  • Include new tests or update existing tests when applicable.
  • Allow maintainers to push and squash when merging my commits.

Closes: #14452

Vlor999 and others added 2 commits May 9, 2026 11:29
Add a new CLI argument --name-only that displays only the test name
or collection error headline when a test fails. This is useful for
quickly identifying failures in large test suites without the noise
of full tracebacks or capture sections.

- Register --name-only in pytest_addoption.
- Modify summary_failures_combined and summary_errors to honor the flag.
- Add regression tests in testing/test_name_only.py.
Co-authored-by: Gemini CLI <gemini-cli@google.com>
@psf-chronographer psf-chronographer Bot added the bot:chronographer:provided (automation) changelog entry is part of PR label May 9, 2026
Comment thread testing/test_name_only.py
@@ -0,0 +1,94 @@
from __future__ import annotations

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The PR tests --name-only with --tb=line, but what about other combinations like --name-only with --show-capture=no or with verbose flags? Consider adding a test that ensures these play nicely together => Add tests for combinations like --name-only -v and document expected behavior

Comment thread src/_pytest/terminal.py
help="Controls how captured stdout/stderr/log is shown on failed tests. "
"Default: all.",
)
group.addoption(

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The --tb=line case doesn't fully honor --name-only intent. The crash line message is still displayed

@Vlor999

Vlor999 commented Jun 15, 2026

Copy link
Copy Markdown
Author

Thanks for the review. I pushed a follow-up that makes --name-only --tb=line show only the failure headline, and added coverage for --name-only -v and --name-only --show-capture=no.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bot:chronographer:provided (automation) changelog entry is part of PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

terminal: add --name-only option to show only names of failed tests

2 participants